package controller.common;

/**
 * Created by Administrator on 2017/8/15.
 */
public class CalculateDistance {

    public static double computedDistance(double wd1, double jd1, double wd2, double jd2)
            throws Exception {
        double x, y, out;
        double PI = 3.14159265;
        double R = 6.371229 * 1e6;

        x = (jd2 - jd1) * PI * R * Math.cos(((wd1 + wd2) / 2) * PI / 180) / 180;
        y = (wd2 - wd1) * PI * R / 180;
        out = Math.hypot(x, y);
        return out;
    }


    @org.junit.Test
    public void test() throws Exception {
        double r = computedDistance(31.047111,121.53714,31.035848,121.538828);
        System.out.print(r);
    }
}
